package com.airn.siege.lion.custom.widget

import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.airn.siege.lion.custom.widget.databinding.ActivityScrollPickerBinding


/**
 * Author: Airn
 * Create On: 2023-11-28
 * E-mail: 1275218537@qq.com
 */
class ScrollPickerActivity : AppCompatActivity() {

    companion object {
        private val TAG: String = ScrollPickerActivity::class.java.simpleName
    }

    private lateinit var binding: ActivityScrollPickerBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //setContentView(R.layout.activity_main)
        binding = ActivityScrollPickerBinding.inflate(layoutInflater)
        setContentView(binding.root)
        Log.i(TAG, "onCreate")

        initData()
        binding.tvAAA.setOnClickListener {
            setAddressSelectorPopup(it)
        }
        binding.tvCCC.setOnClickListener {
            BottomPickerViewUtils.secondOrderLinkagePopup(this@ScrollPickerActivity, it) { selected0, selected1 ->
                Toast.makeText(this@ScrollPickerActivity, "${selected0?.name}-${selected1?.name}", Toast.LENGTH_SHORT).show()
            }
        }


    }

    /**
     * 将选择器放在底部弹出框
     * @param v
     */
    private fun setAddressSelectorPopup(v: View) {
        BottomPickerViewUtils.setAddressSelectorPopup(this@ScrollPickerActivity, v)
    }


    private fun initData() {
        val list: MutableList<String> = ArrayList()
        for (i in 0..19) {
            val itemData = "item: $i"
            list.add(itemData)
        }
    }


}